Skip to content

Fix issue with client-server out-of-sync in case of permission error …#580

Open
olesz wants to merge 1 commit intovertica:masterfrom
olesz:out_of_sync_issue
Open

Fix issue with client-server out-of-sync in case of permission error …#580
olesz wants to merge 1 commit intovertica:masterfrom
olesz:out_of_sync_issue

Conversation

@olesz
Copy link

@olesz olesz commented Feb 13, 2026

Fixes bug (#579)

It seems that the vertica client had an issue consuming ReadyForQuery messages when prepared statements are used and several consecutive queries are rejected with permission error.

Faulty sequence of messages:

2026-02-14 00:26:48.116 [cursor] 2563516822224/13328:0x6a80 <INFO> Bind parameters: ()
2026-02-14 00:26:48.117 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Bind
2026-02-14 00:26:48.117 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Execute
2026-02-14 00:26:48.118 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Sync
2026-02-14 00:26:48.118 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Flush
2026-02-14 00:26:48.119 [connection] 2563516822224/13328:0x6a80 <DEBUG> <= ErrorResponse: Severity: ERROR, Message: Permission denied for relation preparedstmt_test, Sqlstate: 42501, Routine: report_no_priv, File: /data/jenkins/workspace/RE-ReleaseBuilds/RE-Miner/server/vertica/Commands/GrantRevoke.cpp, Line: 532, Error Code: 4367
2026-02-14 00:26:48.119 [connection] 2563516822224/13328:0x6a80 <DEBUG> <= ReadyForQuery: status = in_transaction
2026-02-14 00:26:48.119 [cursor] 2563516822224/13328:0x6a80 <INFO> Bind parameters: ()
2026-02-14 00:26:48.119 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Bind
2026-02-14 00:26:48.120 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Execute
2026-02-14 00:26:48.120 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Sync
2026-02-14 00:26:48.120 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Flush
2026-02-14 00:26:48.121 [connection] 2563516822224/13328:0x6a80 <DEBUG> <= ErrorResponse: Severity: ERROR, Message: Permission denied for relation preparedstmt_test, Sqlstate: 42501, Routine: report_no_priv, File: /data/jenkins/workspace/RE-ReleaseBuilds/RE-Miner/server/vertica/Commands/GrantRevoke.cpp, Line: 532, Error Code: 4367
2026-02-14 00:26:48.122 [cursor] 2563516822224/13328:0x6a80 <INFO> Bind parameters: ()
2026-02-14 00:26:48.122 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Bind
2026-02-14 00:26:48.122 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Execute
2026-02-14 00:26:48.122 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Sync
2026-02-14 00:26:48.123 [connection] 2563516822224/13328:0x6a80 <DEBUG> => Flush
2026-02-14 00:26:48.123 [connection] 2563516822224/13328:0x6a80 <DEBUG> <= ReadyForQuery: status = in_transaction

It seems that when a permission denied error is happening then the server replies with ErrorResponse and ReadyForQuery.

First attempt:

  • self._message in cursor.py is None
  • trying to read BindComplete in _execute_prepared_statement() but ErrorResponse is found -> self._message in cursor.py is sill None
  • ReadyForQuery after ErrorResponse is not consumed

Second attempt:

  • self._message in cursor.py is None
  • ReadyForQuery in buffer is consumed in execute() and stored to self._message
  • trying to read BindComplete in _execute_prepared_statement() but ErrorResponse is found -> self._message in cursor.py is now ReadyForQuery
  • ReadyForQuery after ErrorResponse is not consumed

Third attempt:

  • self._message in cursor.py is ReadyForQuery
  • ReadyForQuery is not consumed in execute() because self._message is ReadyForQuery
  • trying to read BindComplete in _execute_prepared_statement() but ReadyForQuery is found -> raising this anomaly as an exception

This fix introduces an error handler for the prepared statement execution to always set the ErrorResponse as self._message to make it possible for the flush_to_query_ready() in execute() to consume and store ReadyForQuery
Also integration test is added.

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2026

CLA assistant check
All committers have signed the CLA.

@olesz olesz force-pushed the out_of_sync_issue branch from ea01ca8 to 33cdf32 Compare February 13, 2026 23:59
@olesz olesz force-pushed the out_of_sync_issue branch from 33cdf32 to ff1527d Compare February 14, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants